package com.ldk.framework.push;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang.StringUtils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;

/**
 * 推送消息
 * @author xiangwl
 *
 */
public class PushCustomMsg {
	
	/**
	 * 消息模块01专线拼车02包车03快车04顺风车05快递06失物招领
	 * 其实为服务业务代码
	 */
	private String module;

	/**
	 * 消息类型
	 */
	private int type;
	
	/**
	 * 
	 */
	private String key;
	
	/**
	 * 推送通知提示铃声
	 */
	@JSONField(serialize=false)
	private String sound;

	public String getModule() {
		return module;
	}

	public int getType() {
		return type;
	}

	public String getKey() {
		return key;
	}

	public String getSound() {
		return StringUtils.isBlank(sound) ? "default" : sound;
	}


	public void setModule(String module) {
		this.module = module;
	}

	public void setType(int type) {
		this.type = type;
	}

	public void setKey(String key) {
		this.key = key;
	}
	
	public void setSound(String sound) {
		this.sound = sound;
	}
	
	/**
	 * 消息转化为Map
	 * @return
	 */
	public Map<String, String> toMap(){
		Map<String, String> map = new HashMap<String, String>();
		map.put("module", this.module+"");
		map.put("type", this.type +"");
		if(StringUtils.isBlank(key))
			key = "";
		map.put("key", key);
		
		return map;
	}
	/**
	 * 转化为JSON字符串
	 * @return
	 */
	public String toJson(){
		return JSON.toJSONString(this);
	}
}
